<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        /*
        slice
        trim
        indexOf
        replace
        split
        */

        var str1 = '123456789'
        //          012345678
        console.log(str1.slice(0,4))//含头不含尾

        var str2 = ' 123456 '

        console.log(str2.trim())//去掉两端的字符串

        var str3 = '123456789'

        console.log(str3.indexOf(5))//查询下标位置

        var str4 = ' 1 2 3 4 5 6 '
        console.log(str4.replace(/\s/,''))//替换（只能替换一次）
        console.log(str4.replace(/\s/g,''))//全局替换

        var str5 = '1-2-3-4-5-6-7-8-9'

        console.log(str5.split('-'))
    </script>
</body>

</html>